<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragment :: head">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 3 | User Profile</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- DataTables -->
    <link rel="stylesheet" href="../../static/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="../../static/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">

    <!-- Theme style -->
    <link rel="stylesheet" href="../../static/css/adminlte.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../../static/plugins/fontawesome-free/css/all.min.css">

</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
    <!-- Navbar -->
    <nav th:replace="admin/_fragment  ::Navbar" class="main-header navbar navbar-expand navbar-white navbar-light">
        <!-- Left navbar links -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fa fa-bars"></i></a>
            </li>
        </ul>

        <!-- Right navbar links -->
        <ul class="navbar-nav ml-auto">
            <!-- Messages Dropdown Menu -->
            <li class="nav-item dropdown">
                <a class="nav-link" href="../index.html">
                    <i class="fa fa-paper-plane"></i>
                    <span>博客前台首页</span>
                </a>
            </li>
        </ul>
    </nav>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <aside th:replace="admin/_fragment  ::MainSidebarContainer(3)"
           class="main-sidebar sidebar-dark-primary elevation-4">
        <!-- Brand Logo -->
        <h1>
            <a href="../index.html" class="brand-link">
                <img src="../../static/upload/avatar.jpg" class="brand-image img-circle elevation-3">
                <span class="brand-text font-weight-light">ZengZK's Blog</span>
            </a>
        </h1>

        <!-- Sidebar -->
        <div class="sidebar">
            <!-- Sidebar Menu -->
            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
                    data-accordion="false">
                    <!-- Add icons to the links using the .nav-icon class
                         with font-awesome or any other icon font library -->
                    <li class="nav-header">仪表盘</li>
                    <li class="nav-item">
                        <a href="dashboard.html" class="nav-link">
                            <i class="nav-icon fas fa-tachometer-alt"></i>
                            <p>仪表盘</p>
                        </a>
                    </li>
                    <li class="nav-header">博客编辑</li>
                    <li class="nav-item">
                        <a href="edit.html" class="nav-link">
                            <i class="nav-icon fas fa-edit"></i>
                            <p>发布博客</p>
                        </a>
                    </li>
                    <li class="nav-header">管理模块</li>
                    <li class="nav-item">
                        <a href="blog-mgr.html" class="nav-link active">
                            <i class="fa fa-list-alt nav-icon" aria-hidden="true"></i>
                            <p>博客管理</p>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="category-mgr.html" class="nav-link">
                            <i class="fa fa-bookmark nav-icon" aria-hidden="true"></i>
                            <p>分类管理</p>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="tag-mgr.html" class="nav-link">
                            <i class="fa fa-tags nav-icon" aria-hidden="true"></i>
                            <p>标签管理</p>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="comment-mgr.html" class="nav-link">
                            <i class="fa fa-comments nav-icon" aria-hidden="true"></i>
                            <p>评论管理</p>
                        </a>
                    </li>
                    <li class="nav-header">系统管理</li>
                    <li class="nav-item">
                        <a href="configuration.html"
                           class="nav-link">
                            <i class="fa fa-wrench nav-icon"></i>
                            <p>系统配置</p>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="../index.html" class="nav-link">
                            <i class="fa fa-sign-out-alt nav-icon"></i>
                            <p>安全退出</p>
                        </a>
                    </li>
                </ul>
            </nav>
            <!-- /.sidebar-menu -->
        </div>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper mt-3">
        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="card card-teal card-outline">
                            <div class="card-header">
                                <h3 class="card-title">博客列表</h3>
                            </div>
                            <div class="card-body">

                            </div>
                            <hr class="m-0">
                            <!-- /.card-header -->
                            <div class="card-body table-responsive">
                                <table id="testTable" class="table table-bordered table-hover text-nowrap">
                                    <thead>
                                    <tr>
                                        <th><input type="checkbox" value="' + data + '" name="id"/></th>
                                        <th>标题</th>
                                        <th>分类</th>
                                        <th>发布</th>
                                        <th>浏览量</th>
                                        <th>发布时间</th>
                                        <th>更新时间</th>
                                        <th>操作</th>
                                        <!--                    <td>1</td>-->
                                    </tr>
                                    <tr th:each="blog : ${bloglist}">
                                        <td th:text="${blog.id}">1</td>
                                        <td th:text="${blog.title}">1</td>
                                        <td th:each="type:${typelist}" th:if="${type.id==blog.typeId}"
                                            th:text="${type.name}">
                                        </td>
                                        <td th:if="${blog.typeId==0}" th:text="无分类">无分类</td>
                                        <td th:text="${blog.published}==true?'发布':'未发布'">1</td>
                                        <td th:text="${blog.views}">1</td>
                                        <td th:text="${{#dates.format(blog.createTime,'yyyy-MM-dd HH:mm:ss')}}">1</td>
                                        <td th:text="${{#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm:ss')}}">1</td>
                                        <td><input type="button" onclick="tomodify(this)" class="btn btn-primary"
                                                   th:attr="data-id=${blog.id}" value="编辑"> <input
                                                type="button" onclick="delete1(this)" th:attr="data-id=${blog.id}"
                                                class="btn btn-primary"
                                                value="删除"></td>
                                    </tr>

                                    </thead>
                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px">共</span>
                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px"
                                          th:text="${countblog}"></span>
                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px">条</span>
<!--                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px">共</span>-->
<!--                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px"-->
<!--                                          th:text="${pageAll}"></span>-->
<!--                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px">页</span>-->
<!--                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px">第</span>-->
<!--                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px" th:text="${pageindex}"></span>-->
<!--                                    <span style="  margin-left: 50px; color: #00b44e ;font-size: 20px">页</span>-->
                                </table>
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->
                    </div>
                    <!-- /.col -->
                </div>

            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <footer th:replace="admin/_fragment  ::foot" class="main-footer">
        <p class="text-center mb-1">
            Copyright © 2020 ZengZK Designed by ZengZK Powered by AdminLTE
        </p>
        <p class="text-center">
            <a href="">粤ICP备20040058号</a>
        </p>
    </footer>
</div>
<div th:replace="admin/_fragment :: js">
    <!-- ./wrapper -->

    <!-- jQuery -->
    <script src="../../static/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="../../static/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- DataTables -->
    <script src="../../static/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../../static/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="../../static/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="../../static/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>


    <!-- AdminLTE App -->
    <script src="../../static/js/adminlte.min.js"></script>

</div>
<script>

    function tomodify(obj) {
        var id = $(obj).attr('data-id')
        // alert(id)
       location.href='/admin/tomodifyblog?blogid='+id;
    }

    function delete1(obj) {
        var id = $(obj).attr('data-id')
        if (confirm('你确定要删除吗?')) {
            $.ajax({
                url: '/admin/deleteblog',
                data: {'blogid': id},
                success: function (data) {
                    if (data == 'success') {
                        alert('删除成功！')
                        location.href = '/admin/toblog'
                    } else {
                        alert('删除失败！')
                    }
                }
            })
        }
    }


    // $(function () {
    //
    // }


    /**
     * 表格加载渲染完毕后执行的方法
     * @param data
     */
    //     function renderTopPlugin(data) {
    //         //上方topPlugin DIV中追加HTML
    //         //var topPlugin='<button id="addButton" class="btn btn-success btn-sm" data-toggle="modal" data-target="#addUser" style="display:block;">' +
    //         // '<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>添加用户</button>';
    //         //删除用户按钮的HTMLDOM
    //         var topPlugin = '<button class="btn btn-danger btn-sm">批量删除</button> <button class="btn btn-primary btn-sm">新增</button> <button class="btn btn-info btn-sm">导出全部</button>';
    //         $("#topPlugin").append(topPlugin);//在表格上方topPlugin DIV中追加HTML
    //         //$("#expCsv").on("click", exp1);//给下方按钮绑定事件
    //     }
    // });
</script>

</body>
</html>
